home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Freeware 2002 November
/
SGI Freeware 2002 November - Disc 1.iso
/
dist
/
fw_cups.idb
/
usr
/
freeware
/
etc
/
cups
/
install-cups.z
/
install-cups
Wrap
Text File
|
2002-04-08
|
5KB
|
186 lines
#!/bin/sh
#Tag 0x00000610
#
# Author: Andrea Suatoni
#
# $Id: install-cups,v 1.1.1.1 2002/02/01 03:31:12 and Exp $
#
FREEWARE_DIR="/usr/freeware"
CUPS_BIN_FILES="/usr/bin/cancel /usr/bin/disable /usr/bin/enable /usr/bin/lp /usr/bin/lpstat /usr/bsd/lpq /usr/bsd/lpr /usr/bsd/lprm"
CUPS_SBIN_FILES="/usr/etc/lpc /usr/lib/accept /usr/lib/lpadmin /usr/lib/reject"
CUPS_BACKUP_EXT=".cups_backup"
#
# Checks that we are the super-user
#
CheckPermission() {
cid=`/usr/bin/id | /usr/bin/nawk '{print substr($1,index($1,"("))}'`;
if [ "$cid" != "(root)" ]; then
echo "You must be logged in as root to use this program."
exit 1;
fi
}
#
# Backup the IRIX binary passed as first parameter, and create symbolic link to
# the CUPS binary passed as the second parameter
#
InstallCUPSFile() {
if [ \( -f $1 \) -a \( ! -l $1 \) -a \( -f $1$CUPS_BACKUP_EXT \) ]; then
echo "Fatal error: $1 is not linked to CUPS, but has already been backuped by CUPS"
exit 1
fi
if [ \( -l $1 \) -a \( -f $1$CUPS_BACKUP_EXT \) ]; then
echo "$1: already linked to CUPS"
return 0
fi
if [ ! -f $1 ]; then
/sbin/touch $1
fi
/sbin/mv $1 $1$CUPS_BACKUP_EXT
/sbin/ln -s $2 $1
}
#
# Remove the symbolic link to the CUPS binary and restore the original
# IRIX binary (if this last one has zero lenght, it is a dummy placeholder
# created during the CUPS installation and must be removed as well)
#
UninstallCUPSFile() {
if [ ! -f $1$CUPS_BACKUP_EXT ]; then
return 0
fi
/sbin/rm -f $1
if [ -s $1$CUPS_BACKUP_EXT ]; then
/sbin/mv $1$CUPS_BACKUP_EXT $1
else
/sbin/rm -f $1$CUPS_BACKUP_EXT
fi
}
#
# Switch from IRIX to CUPS spooling system
#
InstallCUPS() {
echo ""
echo "================================="
echo "CUPS spooling system installation"
echo "================================="
echo ""
echo "The following IRIX system files will be backuped and a symbolic link"
echo "to the equivalent CUPS binary will be created in their place:"
echo ""
for f in $CUPS_BIN_FILES; do
cupsfile=$FREEWARE_DIR/bin/`basename $f`
echo "$f\t-> $cupsfile"
done
for f in $CUPS_SBIN_FILES; do
cupsfile=$FREEWARE_DIR/sbin/`basename $f`
echo "$f\t-> $cupsfile"
done
echo ""
echo "WARNING\07: Running this script you will modify the behaviour of the default IRIX"
echo " spooling system, which will be switched to CUPS. Also, the default"
echo " IRIX printer spooler lpsched(1M) will be stopped and disabled from"
echo " automatic system startup. It is advisable that before running this"
echo " script you will remove any defined printer from the IRIX spooling"
echo " system. Do not mix IRIX and CUPS printers!"
echo ""
echo "Are you sure you wish to continue? (y/n) [n]: \c"
read yn
if [ \( "$yn" != "y" \) -a \( "$yn" != "Y" \) ]; then
exit 1
fi
for f in $CUPS_BIN_FILES; do
cupsfile=$FREEWARE_DIR/bin/`basename $f`
InstallCUPSFile $f $cupsfile
done
for f in $CUPS_SBIN_FILES; do
cupsfile=$FREEWARE_DIR/sbin/`basename $f`
InstallCUPSFile $f $cupsfile
done
#
# Disable the IRIX printing scheduler
#
[ -x /usr/lib/lpshut ] && /usr/lib/lpshut > /dev/null 2>&1
/sbin/chkconfig lp off > /dev/null 2>&1
#
# Enable the CUPS printing scheduler
#
/sbin/chkconfig cups on > /dev/null 2>&1
echo ""
echo "The CUPS spooling system has been successfully installed."
echo ""
echo "VERY IMPORTANT\07: Please remember to switch back to the IRIX spooling system"
echo " before installing IRIX overlays or upgrades, before removing"
echo " IRIX spooling system, or before removing or upgrading CUPS!"
echo " (use '`dirname $prog`/uninstall-cups' to do it)"
}
#
# Switch from CUPS to IRIX spooling system
#
UninstallCUPS() {
echo ""
echo "==================================="
echo "CUPS spooling system uninstallation"
echo "==================================="
echo ""
echo "The default spooling system will be switched back to the IRIX one."
echo "The symbolic links to CUPS binaries will be removed and the IRIX binaries"
echo "will be restored."
echo ""
echo "Are you sure you wish to continue? (y/n) [n]: \c"
read yn
if [ \( "$yn" != "y" \) -a \( "$yn" != "Y" \) ]; then
exit 1
fi
for f in $CUPS_BIN_FILES; do
UninstallCUPSFile $f
done
for f in $CUPS_SBIN_FILES; do
UninstallCUPSFile $f
done
#
# Disable the CUPS printing scheduler
#
[ -x /etc/init.d/cups ] && /etc/init.d/cups stop > /dev/null 2>&1
/sbin/chkconfig cups off > /dev/null 2>&1
#
# Enable the IRIX printing scheduler
#
/sbin/chkconfig lp on > /dev/null 2>&1
echo ""
echo "The IRIX spooling system has been successfully restored."
}
#########################################################################
#
# Main program
#
#
# Ensure that we are root
#
CheckPermission
#
# See how we have been called (install or uninstall?)
#
prog=$0
op=`basename $prog`
case $op in
install-cups)
InstallCUPS
;;
uninstall-cups)
UninstallCUPS
;;
esac